#include "sendDataTo_st.h"
#include<QDebug>

UdpSender::UdpSender(QObject *parent) : QObject(parent)
{
    udpSocket = new QUdpSocket(this);
    //发送端不绑定固定端口
}

UdpSender::~UdpSender()
{
    udpSocket->close();
    delete udpSocket;
}

void UdpSender::sendData(const QByteArray &data, const QHostAddress &remoteAddr, quint16 remotePort)
{
    qDebug() << "发送数据：" << data<< "到地址：" << remoteAddr.toString() 
             << "端口：" << remotePort;;
    qDebug() << "发送到：" << remoteAddr.toString() << ":" << remotePort;
    udpSocket->writeDatagram(data, remoteAddr, remotePort);

}
